package edit.VMAD;

import java.util.ArrayList;

import edit.HolderInterface;
import edit.StaticRecordHolder;

import skyproc.MajorRecord;
import skyproc.ScriptPackage;
import skyproc.ScriptRef;
import skyproc.Type;

public class ScriptPackageHolder implements HolderInterface {
	
	private ScriptPackage scriptPackage;
	private ArrayList<ScriptRef> scripts;
	
	public ScriptPackageHolder() {
		scriptPackage = ((ScriptPackage) StaticRecordHolder.getRecord().getSubRecords().get(Type.VMAD));
		scripts = scriptPackage.getScripts();
	}

	@Override
	public String getDescription() {
		return "Script Package - VMAD";
	}

	@Override
	public Object getValueAt(int index) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean isLeaf() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public Object getChild(Object parent, int index) {
		
		switch(index) {
		case 0:
			return new VersionHolder();
		case 1:
			return new ObjectFormatHolder();
		case 2:
			return new ScriptCountHolder();			
		}
		
		return new ScriptRefHolder(scripts.get(index - 3), index - 3);
	}

	@Override
	public int getChildCount() {
		// TODO Auto-generated method stub
		return scripts.size() + 3;
	}

	@Override
	public int getIndexOfChild(Object parent, Object child) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public Object getHeldObject() {
		// TODO Auto-generated method stub
		return scriptPackage;
	}

}
